package org.example.java.jvm.gc;

import java.util.concurrent.TimeUnit;

/**
 * Edon优先划分对象测试
 * VM params : -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8 -verbose:gc
 * Edon s0 s1 old
 * 8  1   1  10
 *
 * @author juntao zhang
 */
public class EdenFirst {
    private final static int ONE_MB = 1024 * 1024;

    public static void main(String[] args) throws InterruptedException {
        System.out.println("begin");
        byte[] testCase1, testCase2, testCase3, testCase4;
        TimeUnit.SECONDS.sleep(2);
        System.out.println("1 allocate 2M");
        testCase1 = new byte[2 * ONE_MB];
        TimeUnit.SECONDS.sleep(1);
        System.out.println("2 allocate 2M");
        testCase2 = new byte[2 * ONE_MB];
        TimeUnit.SECONDS.sleep(1);
        System.out.println("3 allocate 2M");
        testCase3 = new byte[2 * ONE_MB];
        TimeUnit.SECONDS.sleep(1);
        //     testCase1 = null;
        //     testCase2 = null;
        //     testCase3 = null;
        System.out.println("4 allocate 2M");
        testCase4 = new byte[2 * ONE_MB];
        TimeUnit.SECONDS.sleep(2);
        System.out.println(testCase4.length);
    }
}
